/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.security.logging.jul;

import org.vacoor.nothing.security.logging.LogWatcher;

import java.util.logging.Handler;
import java.util.logging.LogRecord;

public class RecordHandler extends Handler {
    private final LogWatcher<LogRecord> watcher;

    public RecordHandler(LogWatcher<LogRecord> watcher) {
        this.watcher = watcher;
    }

    public void close() throws SecurityException {}

    public void flush() {}

    public void publish(LogRecord record) {
        if (isLoggable(record)) {
            this.watcher.add(record, record.getMillis());
        }
    }
}